﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DBLayer;
using System.Data;
using System.Data.SqlClient;

namespace BALayer
{
    public class DBGiaoVien
    {
        DAL db = null;
        public DBGiaoVien()
        {
            db = new DAL();
        }
        //Lay Giao Vien
        public DataSet LayGiaoVien()
        {
            return db.ExecuteQueryDataSet("Select* From GiaoVien", CommandType.Text, null);
        }
        public bool ThemGiaoVien(ref string err, string MaGV, string TenGV,string DiaChi,string DienThoai)
        {
            return db.MyExecuteNonQuery("SpThemGiaoVien", CommandType.StoredProcedure, ref err,
                new SqlParameter("@MaGV", MaGV),
                new SqlParameter("@TenGV", TenGV),
                new SqlParameter("@DiaChi", DiaChi),
                new SqlParameter("@DienThoai",DienThoai));
        }
        //Xoa Giao Vien
        public bool XoaGiaoVien(ref string err, string MaGV)
        {
            return db.MyExecuteNonQuery("SpXoaGiaoVien", CommandType.StoredProcedure, ref err,
                new SqlParameter("@MaGV", MaGV));
        }
        //Cap nhat Giao Vien
        public bool CapNhatGiaoVien(ref string err, string MaGV, string TenGV, string DiaChi,string DienThoai)
        {
            return db.MyExecuteNonQuery("SpCapNhatGiaoVien", CommandType.StoredProcedure, ref err,
                new SqlParameter("@MaGV", MaGV),
                new SqlParameter("@TenGv", TenGV),
                new SqlParameter("@DiaChi", DiaChi),
                new SqlParameter("@DienThoai", DienThoai));
        }
    }
}
